$(document).ready(function() {
	var citydata = returnCitySN;
	console.log(citydata.cname);
	$("#citytext").text(citydata.cname);
	//返回对象Object {cip: "122.70.200.146", cid: "110000", cname: "北京市"}
	projectProgress();
	gettotletime();
	getRectification();
});
//工程概况---工程进度
var projectProgress = (function() {
	var prourl = dataport + '/ProjectConditionController/getProjectSchedule';
	$.post(prourl, function(result) {
		var code = result.code;
		var list = result.object;
		if(code == 0) {
			$.each(list, function(idx, obj) {
				var idx = idx + 1;
				var html = '<div class="sc-point' + obj.status + ' point' + idx + '"></div>\
							<hgroup class="text-box box' + obj.status + ' proj' + idx + '" id="status' + idx + '">\
								<h3 class="hy">' + obj.datetime + '</h3>\
								<p class="hy">' + obj.description + '</p>\
							</hgroup>';
				$("#progress").append(html);
				var id = $(".box2").attr("id");
				$(".sc-active").addClass(id);
			})
		}
	})
})

var gettotletime = (function() {
	var timeurl = dataport + '/ProjectConditionController/getProjectTime';
	$.post(timeurl, function(result) {
		var code = result.code;
		var list = result.object;
		if(code == 0) {
			$.each(list, function(idx, obj) {
				$("#totletime").text(obj.totalTime);
				var completedtime = obj.completedTime;
				setTimeout(function() {
					canvas(completedtime);
				}, 300);
			})
		}
	})
})

var getRectification = (function() {
	var quailtyurl = dataport + '/ProjectConditionController/getQuality';
	var safetyurl = dataport + '/ProjectConditionController/getSafety';
	$.post(quailtyurl, function(result) {
		var code = result.code;
		var quailty = result.object;
		if(code == 0) {
			$.each(quailty, function(idx, obj) {
				var quailtytotle = obj.qualityNeedChange;
				var quailtydid = obj.qualityChanged;
				$("#quality-totle").text(quailtytotle);
				$("#quality-did").text(quailtydid);
				var qualityper = (quailtydid / quailtytotle).toFixed(2);
				$.post(safetyurl, function(result) {
					var code = result.code;
					var safety = result.object;
					console.log(result);
					if(code == 0) {
						$.each(safety, function(idx, obj) {
							var safetytotle = obj.safetyNeedChange;
							var safetydid = obj.safetyChanged;
							$("#safety-totle").text(safetytotle);
							$("#safety-did").text(safetydid);
							var safetyper = (safetydid / safetytotle).toFixed(2);
							setTimeout(function() {
								cavas(qualityper, safetyper);
							}, 300);
						})
					}
				})
			})

		}
	})
})